﻿@model ProductOverviewModel
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Web.Models.Catalog;
@{
    bool IsProductListBox = (ViewData["IsProductListBox"] != null ? bool.Parse(ViewData["IsProductListBox"].ToString()) : false);

    //prepare "Add to cart" AJAX link
    string addtocartlink = "";
    var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
    var quantity = 1;
    if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
    {
        addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
    }
    else
    {
        addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, });
    }
}
<div class="product-item" data-productid="@Model.Id">
    <div class="picture">
        <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title">
            <img class="lazy" alt="@Model.DefaultPictureModel.AlternateText"
                 src="@Url.GetBaseUrl("Content/Images/ajax-holder.gif")" data-original="@Model.DefaultPictureModel.ImageUrl"
                 title="@Model.DefaultPictureModel.Title" />
        </a>
    </div>
    <div class="details">
        <h2 class="product-title">
            <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })">@(IsProductListBox ? Model.Name : Model.Name.ToStringLength(50))</a>
        </h2>
        @if (Model.ReviewOverviewModel.AllowCustomerReviews)
        {
            int ratingPercent = 0;
            if (Model.ReviewOverviewModel.TotalReviews != 0)
            {
                ratingPercent = ((Model.ReviewOverviewModel.RatingSum * 100) / Model.ReviewOverviewModel.TotalReviews) / 5;
            }
            <div class="product-rating-box" title="@string.Format(T("Reviews.TotalReviews").Text, Model.ReviewOverviewModel.TotalReviews)">
                <div class="rating">
                    <div style="width: @(ratingPercent)%">
                    </div>
                </div>
            </div>
        }
        @*<div class="description">
                @Html.Raw(Model.ShortDescription)
            </div>*@
        <div class="add-info">
            <div class="prices">
                @if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))
                {
                    <span class="price old-price">@Model.ProductPrice.OldPrice</span>
                }
                <span class="price actual-price">@Model.ProductPrice.Price</span>
                @*@if (Model.ProductPrice.DisplayTaxShippingInfo)
                    {
                        var inclTax = EngineContext.Current.Resolve<IWorkContext>().TaxDisplayType == TaxDisplayType.IncludingTax;
                        //tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
                        //of course, you can modify appropriate locales to include VAT info there
                        <div class="tax-shipping-info">
                            @T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
                        </div>
                        }*@
            </div>
            <div class="buttons">
                @*<input type="button" value="@T("Products.Details")" class="button-1 product-box-detail-button" onclick="location.href='@Url.RouteUrl("Product", new { SeName = Model.SeName })'" />*@
                @if (!Model.ProductPrice.DisableBuyButton)
                {
                    var addToCartText = T("ShoppingCart.AddToCart").Text;
                    if (Model.ProductPrice.IsRental)
                    {
                        addToCartText = T("ShoppingCart.Rent").Text;
                    }
                    if (Model.ProductPrice.AvailableForPreOrder)
                    {
                        addToCartText = T("ShoppingCart.PreOrder").Text;
                    }
                    <button type="button" data-addcartlink="@addtocartlink" class="product-box-add-to-cart-button btn btn-success btn-xs">@(addToCartText)</button>
                }
            </div>
            @Html.Widget("productbox_add_info", Model.Id)
        </div>
    </div>
</div>
